<?php
    class CheckTable{
        private $db;
        var $query;
        function __construct($db,$query) {
            $this -> query = $query;            
            $this -> db = $db;            
        }
        function table_data(){
            $stmt = $this -> db ->query($this->query);    
            $finfo = $stmt->fetch_fields();
            $stmt -> free_result();
            $tables=Array();
            foreach ($finfo as $val) {
                $tables[]=strtoupper($val->name);
            }
            return $tables;
        }
        function column_exist($target){
            if(is_array($target)){
                $return = false;
                foreach ($target as $key => $value) {
                    if(in_array(strtoupper($value), $this->table_data())){
                        $return = true;
                    }
                }
                return $return;
            }else{
                return in_array($target,$this->table_data());
            }            
        }
        function __destruct(){
            echo '<p>'.__CLASS__.' ended</p>';
        }
    }
?>